<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.nwpu.vote.model.*" %>
<%@ page import="com.nwpu.vote.control.*" %>
<%@ page import="java.util.List" %>

<html>
  <head>
  	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>西工大投票系统</title>
    <link type="text/css" rel="stylesheet" href="css/main.css">
  </head>

  <body>
  	<div class="header">
  		<div class="logo"></div>
  		<div class="right">
  			<a href="login.html">登录</a>
		</div>
		<div class="right">
  			<a href="newUser.jsp">新建用户</a>
		</div>
  	</div>
	
	<div style="clear:both"> </div>
	<div class="leader">
		<div class="menu">
			<a class="active" href="index.jsp">主页</a>
			<a href="newVote.jsp">新建投票</a>
			<a href="listHistory.jsp">历次投票</a>
			<a href="search.jsp">查找</a>
			<a href="help/howto.html" target="_blank">使用说明</a>
			<a href="help/about.html" target="_blank">关于</a>
		</div>
	</div>
	<div class="main" style="clear:both;padding:8px;">
	  <table width="100%" border="0" cellspacing="2" cellpadding="2">
	    <tr> 
	      <td width="49%"> 
	        <div style="font-size:20px;line-height:32px;font-weight:bold;">当前公开的投票</div>
	        <div class="item">
	            	
					<%	
					List<Vote> openingVotes = VoteQuerierImpl.instance.listOpeningVotes();
					for(Vote vote: openingVotes){
						%><a href="/vote?id=<%=vote.getKey().getId()%>" target="_blank"><%=vote.getTitle()%></a><br/>				
					<%}%>
						
	         </div>
	      </td>
	      <td width="30%" rowspan="3" valign="top" style="background-color:#E5ECF9;"> 
	        <div style="padding:6px;height:400px;"> 
	            <div class="title">最近的投票</div>
	            <div class="item">
	            	
					<%	
					List<Vote> recentVotes = VoteQuerierImpl.instance.listRecentVotes(5);
					for(Vote vote: recentVotes){
						%><a href="/voteinfo?id=<%=vote.getKey().getId()%>" target="_blank"><%=vote.getTitle()%></a><br/>				
					<%}%>
						
	            </div>
	            <div class="title" style="margin-top:30px">最近参与投票的用户</div>
	            <div class="item" >
	            	
					<%	
					List<VoteUser> activeUsers = VoteQuerierImpl.instance.listActiveUsers(5);
					for(VoteUser user : activeUsers){
						%><a href="/userinfo?username=<%=user.getName()%>" target="_blank"><%=user.getName()%></a><br/>				
					<%}%>
						
	            </div>
	        </div>
	      </td>
	    </tr>
	    <tr> 
	      <td colspan="2">
	      	<ul>
	          <p><a href="mailto:richardroky@gmail.com?subject=feedback for NwpuVote">意见反馈</a></p>
	        </ul>
	      </td>
	    </tr>
	  </table>
	</div>
	
  </body>
</html>
